<template>
    <view>
        <custom><template #backText>商品分类</template></custom>
        <crud ref="crud" :title="crud.title" :url_list="crud.url_list" :url_update="crud.url_update" :form.sync="crud.form">
            <template #list="data">
                <nMenuItemContentAction v-for="(info, key) in data.list" :key="key" class="bg-white">
                    <template #content>
                        <view class="flex justify-between">
                            <view>{{info.name}}</view>
                            <view class="text-gray text-df">
                                <text class="cuIcon-sort margin-right-6"></text>
                                <text>{{info.sort}}</text>
                            </view>
                        </view>
                        <view class="flex justify-between">
                            <view>
                                <view class="cu-tag" v-if="info.open_status == 0">下架</view>
                                <view class="cu-tag bg-nddyny" v-if="info.open_status == 1">上架</view>
                                <view class="cu-tag" v-if="info.audit_status == 0">正在审核</view>
                                <view class="cu-tag bg-nddyny" v-if="info.audit_status == 1">已审核</view>
                                <view class="cu-tag bg-red" v-if="info.audit_status == 2">审核失败</view>
                            </view>
                            <view>
                                <nButton title="删除" bg="bg-red" class="sm" :tap="()=>{$refs.crud.delete(info)}"></nButton>
                                <nButton title="编辑" class="margin-left-10 sm" :tap="()=>{$refs.crud.update(info)}"></nButton>
                            </view>
                        </view>
                    </template>
                </nMenuItemContentAction>
            </template>
            <template #form="data">
                <template v-if="data.data.form.is_delete==1">
                    <view class="text-center">确定要删除商品分类“{{data.data.form.name}}”吗？</view>
                </template>
                <template v-else>
                    <nFormItem key="form_open_status" type="switch" title="上架状态" :data.sync="data.data" field="open_status" :disabled="data.data.form.is_delete==1?true:false"></nFormItem>
                    <nFormItem key="form_sort" title="商品排序" format="number" :data.sync="data.data" field="sort"
                        :disabled="data.data.form.is_delete==1?true:false"></nFormItem>
                    <nFormItem key="form_name" title="商品分类" :data.sync="data.data" field="name" :disabled="data.data.form.is_delete==1?true:false"></nFormItem>
                </template>
            </template>
        </crud>
    </view>
</template>

<script>
    import crud from '@/components/nddyny/crud.vue';
    export default {
        components: {
            crud,
        },
        data() {
            return {
                crud: {
                    title: '商品分类',
                    url_list: '/seller/item/typeList',
                    url_update: '/seller/item/updateType',
                    form: {
                        item_type_id: '',
                        is_delete: '',
                        
                        name: '',
                        sort: '0',
                        open_status: '1'
                    }
                }
            };
        },
        onLoad() {},
        methods: {},
    }
</script>
